function screen_init() {
	$("#create_btn").click(function() {
			$(this).parent().hide();
			$("#newtopic").show();
			});
	$("#cancel_btn").click(function() {
			$("#create_btn").parent().show();
			$("#newtopic").hide();
			});
	$("#btn_autopub").click(function(){
			var link = $(this);
			var url='/screen/aj_auto_pub.php';
			var auto = 0;
			if(link.attr("checked")){
				auto = 1;
			}
			var pars='id='+link.attr('rel')+'&auto='+auto;
			$.ajax({
				type: "POST",
				url: url,
				data: pars,
				dataType: "json",
				success: function(json){
					if(json.status=='1'){
						alert('设置成功');
					}else{
						alert('设置失败');
					}
				}
				});
			});
	$(".btn_stop").click(function(){
			var link=$(this);
			$("#confirm_div_text").text("你确定停止当前活动吗？");
			$("#confirm_div").showMiddleDialog(["confirm_close", "confirm_ok", "confirm_cancel"], function() {
				if ($(this).attr("id") != "confirm_ok") {
					return;
				}
				var url='/screen/screen_action.php';
				var pars='action=endtopic&id='+link.attr("rel");
						$.ajax({
							type: "POST",
							url: url,
							data: pars,
							dataType: "json",
							success: function(json){
								if(json.status==1){
								window.setTimeout(function(){
									window.location='/screen/screen.php';
									},1000);
								}
								else{
									$("#confirm_div_text").text(json.msg);
									$("#confirm_div").showMiddleDialog(["confirm_close", "confirm_ok", "confirm_cancel"]);
								}
							} 
						});
			});
	});
	//删除活动
	$("#del_btn").click(function(){
			var link=$(this);
			$("#confirm_div_text").text("你确定删除当前活动吗？");
			$("#confirm_div").showMiddleDialog(["confirm_close", "confirm_ok", "confirm_cancel"], function() {
				if ($(this).attr("id") != "confirm_ok") {
					return;
				}
				var url='/screen/screen_action.php';
				var pars='action=del&id='+link.attr("rel");
						$.ajax({
							type: "POST",
							url: url,
							data: pars,
							dataType: "json",
							success: function(json){
								if(json.status==1){
									window.location='/screen/screen.php';
								}
								else{
									$("#confirm_div_text").text(json.msg);
									$("#confirm_div").showMiddleDialog(["confirm_close", "confirm_ok", "confirm_cancel"]);
								}
							} 
						});
			});
	});
	//开始活动
	$("#start_btn").click(function(){
			var link=$(this);
			$("#confirm_div_text").text("你确定立即开始活动吗？");
			$("#confirm_div").showMiddleDialog(["confirm_close", "confirm_ok", "confirm_cancel"], function() {
				if ($(this).attr("id") != "confirm_ok") {
					return;
				}
				var url='/screen/screen_action.php';
				var pars='action=starttopic&id='+link.attr("rel");
						$.ajax({
							type: "POST",
							url: url,
							data: pars,
							dataType: "json",
							success: function(json){
								if(json.status==1){
								window.setTimeout(function(){
									window.location='/screen/screen.php?id='+link.attr("rel");
									},1000);
								}
								else{
									$("#confirm_div_text").text(json.msg);
									$("#confirm_div").showMiddleDialog(["confirm_close", "confirm_ok", "confirm_cancel"]);
								}
							} 
						});
			});
	});
	//查看中奖信息
	$(".viewaward").click(function(){
			var link=$(this);
			var w =580 ;
			var h = 580;
			var s = "no";
			var target = "viewuserinfo";
			var url="/screen/screen_award.php?id="+link.attr("rel");
			var left=(screen.width-w)/2;
			var top=(screen.height-h)/2;
			var r = window.open(url,target,'width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=1,resizable=0,status='+s);
			r.focus();
			});
	//查看短信注册信息
	$(".smsreg").click(function(){
			var link=$(this);
			var w =580 ;
			var h = 580;
			var s = "no";
			var target = "viewuserinfo";
			var url="/screen/screen_smsreg.php?id="+link.attr("rel");
			var left=(screen.width-w)/2;
			var top=(screen.height-h)/2;
			var r = window.open(url,target,'width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=1,resizable=0,status='+s);
			r.focus();
			return r;
			});
  }
$(document).ready(function(){screen_init();});
